tpl1="""
execute store result score @s advm_power run data get entity @s Inventory[-1].tag.power
{part_get_slot_cost}
execute if score @s advm_power matches 1.. run scoreboard players operation @s advm_power -= @s advm_power_cost
execute if score @s advm_power matches ..0 run scoreboard players set @s advm_power 0
execute store result storage advm:temp power int 1 run scoreboard players get @s advm_power
item modify entity @s weapon.offhand advm:set_power
execute as @s[nbt={{Inventory:[{{Slot:-106b,tag:{{id:"advm:battery"}}}}]}}] if score @s advm_power matches ..0 run loot replace entity @s weapon.offhand loot advm:battery_used_up
"""
tpl2="""
execute if score @s advm_useSlot matches {id} run execute store result score @s advm_power_cost run data get entity @s Inventory[{{Slot:{id}b}}].tag.power_cost
execute if score @s advm_useSlot matches {id} run execute if data entity @s Inventory[{{Slot:{id}b}}].tag.electricalAttribute.hyperload run scoreboard players operation @s advm_power_cost += @s advm_power_cost
execute if score @s advm_useSlot matches {id} run execute if data entity @s Inventory[{{Slot:{id}b}}].tag.electricalAttribute.efficient_use run scoreboard players operation @s advm_power_cost /= @s advm_efficient_use_devide
"""

tpl3=""

with open("gen.txt","w+") as f:
    for i in range(0,36): 
        tpl3+=tpl2.format(id=str(i))
    for i in range(100,104): 
        tpl3+=tpl2.format(id=str(i))
    f.write(tpl1.format(part_get_slot_cost=tpl3))